#pragma once

#include "qconf.h"

namespace qio {

class SSLHelper {
 public:
  SSLHelper() = default;

  SSLHelper(const SSLHelper &) = delete;

  SSLHelper &operator=(const SSLHelper &) = delete;

  virtual SSL_CTX *GetSSLContext() const = 0;

  virtual ~SSLHelper() = 0;
};

class SSLConfig final : public SSLHelper {
 public:
  SSLConfig(const std::string &cert_file,
            const std::string &priv_file) QIO_NOEXCEPT;

  ~SSLConfig() QIO_NOEXCEPT final;

  SSL_CTX *GetSSLContext() const QIO_NOEXCEPT override;

 private:
  void Build() QIO_NOEXCEPT;

 private:
  std::string cert_file_;
  std::string priv_file_;
  SSL_CTX *ssl_ctx_;
};

using SharedSSLHelper = std::shared_ptr<SSLHelper>;

}  // namespace qio
